/*
 ============================================================================
 Name        : commandProcess.c
 Author      :
 Version     :	1
 Copyright   : Your copyright notice
 Description : Executes the different  input commands
 ============================================================================
 */

#include "commandProcess.h"
#include "consoleParser/consoleParser.h"
commandsFunction commands[] = ///<Array of commands functions
{
{ RAW_DUMP, rawPrint },
{ HEADER_DUMP, printHeaders },
{ PROCESS_HEADER_CONTENT, processHeaders },
{ HELP, printHelp},
{ 0, 0 } };
/*! \fn processInput(char * commandBuffer, int fd)
\brief Execute the process associated with each command in the buffer
\param commandBuffer Buffer of the different commands to be execute
\param fd pointer to the file to be process
*/
char processInput(char * commandBuffer, int fd)
{
	char status;
	//commandsFunction *pFunc = commands;
	while (*commandBuffer)
	{
		commandsFunction *pFunc = commands;
		while (pFunc->inCharacter != 0)
		{
			if (*commandBuffer == pFunc->inCharacter)
			{
				//PRINT_DEBUG(DEBUG_ALL,"Processing %c...\n", *commandBuffer);
				status = pFunc->func(fd);
				ERROR_HANDLE(status);
			}
			pFunc++;
		}
		commandBuffer++;
	}
	return STATUS_SUCCESS;
}
